--
--	所有货币的共有结构
--

local Daibi = class("Daibi")

function Daibi:ctor()
	self.itemBagType = Enums.ItemBagType.daibi

	self.tid = 0
	self.amount = 0
end

function Daibi:read(value)
	self.tid = value.tid
	self.amount = value.amount

	self.conf = GD:getCoinConfig(self.tid)
	self.quality = tonumber(self.conf.quality or 1)
	self._icon = nil
	self._smallIcon = nil
end

function Daibi:getId()
	return self.tid
end

function Daibi:setAmount(num)
	self.amount = num
end

function Daibi:getAmount()
	return self.amount
end

function Daibi:setLevel(level)
	self.level = level
end

function Daibi:getLevel()
	return self.level
end

function Daibi:getQuality()
	return self.quality
end

-- 为了兼容
function Daibi:isClassAvatarEnable()
	return false
end

-- 小icon
function Daibi:getSmallIcon()
	if not self._smallIcon then
		self._smallIcon = string.format("%s%s.png", Res.coinIconPath, self.conf.icon)
	end
	return self._smallIcon
end

-- bg
function Daibi:getIconBg()
	return Res.Qulity_Icon_Bg[self.quality]
end

-- 大icon
function Daibi:getIcon()
	if not self._icon then
		self._icon = string.format("%s%s.png", Res.coinIconPath, self.conf.bigicon)
	end
	return self._icon
end

function Daibi:getName()
	return L(self.conf.name)
end

function Daibi:getDesc()
	return L(self.conf.des)
end

-- 类型名字
function Daibi:getTypeName()
	local showType = self.conf.showType
	if showType and showType ~= "0" then
		return L(Res.showTypeName .. showType)
	end
	return ""
end

return Daibi
